package com.miaoshare.core.base;

import android.app.Activity;
import android.content.Context;

import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.miaoshare.core.utils.imageLoad.ImageManager;

import java.util.List;

import demo.ywd.com.listenerlibrary.NetworkListener;

/**
 * Created by HeroSun
 * date 2022-01-18
 **/
public class BaseApp extends MultiDexApplication {
    //SingleInstance.class
    private volatile static BaseApp mSingleInstance = null;
    /*用于存放所有启动的Activity的集合*/
    private List<Activity> oList;

    /*单例*/
    public static BaseApp getInstance() {
        if (mSingleInstance == null) {
            synchronized (BaseApp.class) {
                if (mSingleInstance == null) {
                    mSingleInstance = new BaseApp();
                }
            }
        }
        return mSingleInstance;

    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        // 图片加载器
        ImageManager.get().init(this);
        //注册网络监听
        NetworkListener.getInstance().init(this);
        // OSS
//        UploadFileUtil.get().init(this);
    }

    //获取应用包名
    public String getPackage() {
        return getPackageName();
    }
}
